# Create your models here.

from django.db import models


class ArticleTags(models.Model):
    tag_name = models.CharField(max_length=100, null=False, blank=False, unique=True)

    class Meta:
        verbose_name = "tags"
        verbose_name_plural = "tags"
        db_table = "articles_tags"


class ArticleCategory(models.Model):
    category_name = models.CharField(max_length=100, null=False, blank=False, unique=True)

    class Meta:
        verbose_name = "category"
        verbose_name_plural = "category"
        db_table = "article_category"


class Article(models.Model):
    title = models.CharField(verbose_name="标题", max_length=100)
    author = models.CharField(verbose_name="作者", max_length=100)
    description = models.TextField(verbose_name="摘要", null=True, blank=True)
    tags = models.ManyToManyField(ArticleTags, verbose_name="标签")
    content = models.TextField(verbose_name="内容")
    view_count = models.IntegerField(verbose_name="浏览数量", default=0)
    create_date = models.DateTimeField(verbose_name="发表日期", auto_now_add=True)
    update_time = models.DateTimeField(verbose_name="更新时间", auto_now=True)

    class Meta:
        verbose_name = "articles"
        verbose_name_plural = "articles"
        db_table = "article"
